package com.gfxy.modules.index.controller;

import com.gfxy.modules.index.service.DepartmentIndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @author: lijixin 2021/9/12 5:54 下午
 */
@Api(tags="分页首页报表")
@RestController
@RequestMapping("index/departmentIndex")
@Slf4j
public class DepartmentIndexController {

    @Autowired
    private DepartmentIndexService departmentIndexService;

    @AutoLog(value = "按年查询课时信息")
    @ApiOperation(value="按年查询课时信息", notes="按年查询课时信息")
    @GetMapping(value = "/listClasstimeByYearAndOrgCode")
    public Result<?> listClasstimeByYear(@RequestParam(name="date",required=true) String date,
                                         @RequestParam(name="orgCode",required=true) String orgCode,
                                   HttpServletRequest req) {
        log.debug("开始查询{}年{}分院的课时信息",date, orgCode);
        Map<String, String> result = departmentIndexService.getTotalClasstimeByYear(date, orgCode);
        return Result.OK(result);
    }

    @AutoLog(value = "按年查询课时类型占比")
    @ApiOperation(value="按年查询课时类型占比", notes="按年查询课时类型占比")
    @GetMapping(value = "/teacherClassTimeByYearAndOrgCode")
    public Result<?> classTimeProportionByYear(@RequestParam(name="date",required=true) String date,
                                               @RequestParam(name="orgCode",required=true) String orgCode,
                                   HttpServletRequest req) {
        log.debug("开始查询{}年{}分院的课时排名信息",date,orgCode);
        Map<String,List> result = departmentIndexService.getTeacherRankByYear(date,orgCode);
        return Result.OK(result);
    }
}
